package com.bjpowernode.crm.workbench.service.Impl;

import com.bjpowernode.crm.settings.dao.UserDao;
import com.bjpowernode.crm.settings.domain.User;
import com.bjpowernode.crm.workbench.dao.ActivityDao;
import com.bjpowernode.crm.workbench.dao.ActivityRemarkDao;
import com.bjpowernode.crm.workbench.domain.Activity;
import com.bjpowernode.crm.workbench.domain.ActivityRemark;
import com.bjpowernode.crm.workbench.service.ActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * ClassName:ActivityImpl
 * package:com.bjpowernode.crm.workbench.service.Impl
 * Description:
 *
 * @date: 2022-06-01 22:52
 * @author：lin
 */

@Service
public class ActivityImpl implements ActivityService {

    @Autowired
    private ActivityDao activityDao;

    @Autowired
    private ActivityRemarkDao remarkDao;

    @Autowired
    private UserDao userDao;

    @Override
    public void saveActivity(Activity activity) {
        activityDao.saveActivity(activity);
    }

    @Override
    public Map<String, Object> searchActivity(Map<String, Object> map) {
        Map<String,Object> pageMap =new HashMap<>();
        List<Activity> dataList =activityDao.searchActivity(map);
        int searchCount = activityDao.searchActivityCount(map);
        pageMap.put("dataList",dataList);
        pageMap.put("searchCount",searchCount);

        return pageMap;
    }

    @Override
    public void deleteActivity(String[] ids) {
        remarkDao.deleteActivityId(ids);
        activityDao.deleteActivity(ids);



    }

    @Override
    public Map<String, Object> getUserAndActivityByid(String id) {
        Map<String,Object> map = new HashMap<>();
        List<User> dataList =userDao.getUser();
        Activity a = activityDao.getActivityById(id);
        map.put("dataList",dataList);
        map.put("a",a);


        return map;
    }

    @Override
    public void updateActivity(Activity activity) {

        activityDao.updateActivity(activity);

    }

    @Override
    public List<Activity> exportActivityAll() {
        return activityDao.exportActivityAll();
    }

    @Override
    public List<Activity> searchActivityById(String[] id) {
        return activityDao.searchActivityById(id);
    }

    @Override
    public int importActivity(List<Activity> activityList) {


        return   activityDao.importActivity(activityList);
    }

    @Override
    public Activity getActivityById(String id) {
        Activity activity= activityDao.searchActivityId(id);

        return activity;
    }

    @Override
    public List<Activity> activityByClueId(String id) {
        return activityDao.activityByClueId(id);
    }

    @Override
    public List<Activity> activityAll(Map map) {
        return activityDao.activityAll(map);
    }


}
